import java.util.ArrayList;
import java.util.List;

public class PalindromeGenerator {
    public static int[] getHui(int min, int max) {
        List<Integer> list = new ArrayList<>();

        // 生成介于min和max之间的所有回文数
        generatePalindromes(min, max, list);

        int[] result = new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            result[i] = list.get(i);
        }

        return result;
    }

    private static void generatePalindromes(int min, int max, List<Integer> list) {
        for (int len = 1; len <= String.valueOf(max).length(); len++) {
            generatePalindromesWithLength(len, list, min, max);
        }
    }

    private static void generatePalindromesWithLength(int len, List<Integer> list, int min, int max) {
        int upperBound = (int) Math.pow(10, (len + 1) / 2);
        for (int i = 0; i < upperBound; i++) {
            String prefix = String.valueOf(i);
            StringBuilder palindrome = new StringBuilder(prefix);
            if (len % 2 == 0) {
                palindrome.append(new StringBuilder(prefix).reverse());
            } else {
                palindrome.append(new StringBuilder(prefix.substring(0, prefix.length() - 1)).reverse());
            }
            int palindromeNum = Integer.parseInt(palindrome.toString());
            if (palindromeNum >= min && palindromeNum <= max) {
                list.add(palindromeNum);
            }
        }
    }

    public static void main(String[] args) {
        int min = 1000;
        int max = 3000;
        int[] hui = getHui(min, max);
        for (int num : hui) {
            System.out.println(num);
        }
    }
}
